<?php 
$GLOBALS['Md'] = "TimeClock";
$GLOBALS['Pd'] = "R";
require_once($_SERVER['DOCUMENT_ROOT']."/defaultconf.mex");
print heade(); 
module($BSD['DB00']);
include($GLOBALS['PAD']."Modules/Exchange/main.obj.php");
include($GLOBALS['PAD']."Modules/Exchange/Reports/views.inc.php");
?>
<script charset="utf-8" type="text/javascript">window.print();</script>
<table width="100%"  border="0" cellpadding="10">
<tr>
<td><h3>Relat�rio de Opera��es | Exchange | MoneyExpress</h3></td>
</tr>
</table>
<table width="100%"  border="0" cellpadding="10">
<?php

 $CSS['PrintClass'] = "Noforms";
 $CSS['lines'] = "<hr width=\"100%\" size=\"1\" height=\"1\"";
			$time_ini = $_POST['time_ini'];
			$time_end = $_POST['time_end'];

if (isset($_POST['View'])) {
	$View = $_POST['View'];
	} elseif (isset($_GET['View'])) {
	$View = $_GET['View'];
	}

	$query_ini = '';
	 $query_end = '';
	 $query_office = '';
	 $query_type = '';
	 $query_in = '';
	 $query_out = '';
	 $query_rates = '';

		for ($S = 0; $S <= $_SESSION['modules_total']; $S++) {
		$M = "Module".$S;
		$P = "Perm".$S;
		if ($_SESSION[$M] == "12") {
		$p = $_SESSION[$P];
		} else {
		$p = 'Perm1';
		}
	}

if ($_SESSION[$p] == 'B') { ?>
  <tr>
    <td>
 <?php if (isset($View)) { ?>

           <table width="100%"  border="0" cellpadding="10" cellspacing="1">
        <?php 	

  if (isset($View) && $View == "Days") {   

  	if (isset($View) && $View == "All") {   
	 print main($time_ini,$time_end);
	
	}
	if (isset($View) && $View == "Days") {
	
	print days($time_ini,$time_end,$CSS);
       
	} 
	if (isset($View) && $View == "Offices") {
			
		print offices($time_ini,$time_end,"B",$_POST['office'],$CSS);
	}
	if (isset($View) && $View == "Details") {
 ?>			
    </table>
      <?php echo details($time_ini,$time_end,$_POST['office']);?>
    </td>
  </tr>
 <?php } 
  } else {	
  	if (isset($View) && $View == "AllDetails") {
 ?>			
    </table>
      <?php echo alldetails($time_ini,$time_end,$CSS);?>
    </td>
  </tr>
  <?php }
  }
  	}
  } elseif($_SESSION[$p] == 'R' || $_SESSION[$p] == 'S') { 
   if (isset($View)) { ?>
  <tr>
    <td>
	<?php

	$QOffice = "SELECT * FROM main_offices WHERE ref = '{$_SESSION[$SESSOF]}'";
	$Office = $GLOBALS['CONN']->db_array($QOffice); ?>
	<h4><?php echo $Office[1]['office_number'];?> | <?php echo $Office[1]['name'];?></h4>
	<p>Total de operaÇ&otilde;es do dia</p>
	<?php
	print offices($time_ini,$time_end,"S",$_SESSION[$SESSOF],$CSS); ?>
	<p>Detalhe das opera��es do dia</p>
	<?php
	print details($time_ini,$time_end,$_SESSION[$SESSOF],$CSS);?>
	</td>
  </tr>
  
  <?php } 
  } ?>
</table>
<?php print footer(); ?>